# This is the main CMAKE for building HTAP
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} TGT_htap_SRC)

set(CMAKE_VERBOSE_MAKEFILE ON)
#set(CMAKE_RULE_MESSAGES OFF)
#set(CMAKE_SKIP_RPATH TRUE)

# we need MOT definitions
set(MOT_CORE_PATH ../mot/core)
set(MOT_CORE_INCLUDE_PATH
    ${MOT_CORE_PATH}/concurrency_control
    ${MOT_CORE_PATH}/infra
    ${MOT_CORE_PATH}/infra/config
    ${MOT_CORE_PATH}/infra/containers
    ${MOT_CORE_PATH}/infra/stats
    ${MOT_CORE_PATH}/infra/synchronization
    ${MOT_CORE_PATH}/memory
    ${MOT_CORE_PATH}/memory/garbage_collector
    ${MOT_CORE_PATH}/storage
    ${MOT_CORE_PATH}/storage/index
    ${MOT_CORE_PATH}/storage/sentinel
    ${MOT_CORE_PATH}/system
    ${MOT_CORE_PATH}/system/checkpoint
    ${MOT_CORE_PATH}/system/common
    ${MOT_CORE_PATH}/system/recovery
    ${MOT_CORE_PATH}/system/statistics
    ${MOT_CORE_PATH}/system/transaction
    ${MOT_CORE_PATH}/system/transaction_logger
    ${MOT_CORE_PATH}/system/transaction_logger/group_synchronous_redo_log
    ${MOT_CORE_PATH}/system/transaction_logger/synchronous_redo_log
    ${MOT_CORE_PATH}/utils
)

set(TGT_htap_INC
    ${PROJECT_SRC_DIR}/include
    ${PROJECT_SRC_DIR}/include/storage/htap
    ${MOT_CORE_INCLUDE_PATH}
    ${ZLIB_INCLUDE_PATH}
        ../mot/fdw_adapter
)

set(htap_DEF_OPTIONS ${MACRO_OPTIONS})
if("${USE_ASSERT_CHECKING}" STREQUAL "ON")
    list(APPEND htap_DEF_OPTIONS -DDEBUG)
endif()
set(htap_COMPILE_OPTIONS ${OPTIMIZE_OPTIONS} ${OS_OPTIONS} ${PROTECT_OPTIONS} ${WARNING_OPTIONS} ${BIN_SECURE_OPTIONS} ${CHECK_OPTIONS})
set(htap_LINK_OPTIONS ${BIN_LINK_OPTIONS})
add_static_objtarget(gausskernel_storage_htap TGT_htap_SRC TGT_htap_INC "${htap_DEF_OPTIONS}" "${htap_COMPILE_OPTIONS}" "${htap_LINK_OPTIONS}")

install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/htap.conf
    DESTINATION share/postgresql
    RENAME htap.conf.sample
)

install(FILES ${3RD_PATH}/kernel/dependency/masstree/comm/lib/libmasstree.so
    DESTINATION lib
    PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
)

